USE [AnotherSuccessfulProcedure]

IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[PlayerNameSingleNameSelectByPlayerId]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
	DROP PROCEDURE dbo.PlayerNameSingleNameSelectByPlayerId
END


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Neil Wilson
-- Create date: 09/03/08
-- Description:	PlayerStatsTeam Table Select By PlayerId and LogId
-- =============================================
CREATE PROCEDURE PlayerNameSingleNameSelectByPlayerId

            @PlayerId varchar(30),
			@ReturnName varchar(30) = null OUTPUT
	
AS

BEGIN



SELECT @ReturnName = PlayerName FROM 

(SELECT COUNT(PlayerName) AS Frequency, PlayerName, PlayerId as PlayerID FROM PlayerNameList
GROUP BY PlayerName, PlayerId ) as NewTable

WHERE PlayerId = @PlayerID 
GROUP BY PlayerName



END
GO